package 笔试2.杀毒;

import org.junit.Test;

import java.util.Arrays;

public class Main {
    @Test
    public void test() {
        int[] old = {6,6,6,6,2,3,3,3};
        int[] xin = new int[old.length];
        xin[0]=old[0];

        for (int i = 1; i < old.length - 1; i++) {

            int cur=old[i],lf=xin[i-1], rt=old[i+1];
            System.out.println(lf+","+cur+","+rt);
            if(lf>cur || rt>cur){
                xin[i]=old[i];
                continue;
            }else{
                if(lf>cur){
                    xin[i]=rt-1;
                }
                else if(rt>cur){
                    xin[i]=lf-1;
                }
                else {
                    if (cur - lf <= cur - rt) {
                        xin[i] = lf - 1;
                    } else xin[i] = rt - 1;
                }
//                xin[i]=Math.max(lf,rt)-1;
            }
        }
        System.out.println(Arrays.toString(xin));

    }
}
